package com.songcha.library_business.bean.book

import android.os.Parcel
import android.os.Parcelable

data class BookDetailBean(var id:String="",
                    var bookName:String="",
                    var thumb:String="",
                    var isFromSDCard:Boolean=false,
                    var path:String="",
                    var fontPath:String="",
    var author:String="",
    var catalog:String="",
    var update:String="",
    var textCount:Int=0,
    var chapterCount:Int=1,
    var desc:String="",

    var status:Int=0,
    var channelId:Int=0,
    var isVip:Int=0,
    var cid:Int=0,
    var averageRating:Float=1.0f

): Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readByte() != 0.toByte(),
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readInt(),
        parcel.readInt()?:1,
        parcel.readString()?:"",
        parcel.readInt(),
        parcel.readInt(),
        parcel.readInt(),
        parcel.readInt(),
        parcel.readFloat()
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(id)
        parcel.writeString(bookName)
        parcel.writeString(thumb)
        parcel.writeByte(if (isFromSDCard) 1 else 0)
        parcel.writeString(path)
        parcel.writeString(fontPath)
        parcel.writeString(author)
        parcel.writeString(catalog)
        parcel.writeString(update)
        parcel.writeInt(textCount)
        parcel.writeInt(chapterCount)
        parcel.writeString(desc)
        parcel.writeInt(status)
        parcel.writeInt(channelId)
        parcel.writeInt(isVip)
        parcel.writeInt(cid)
        parcel.writeFloat(averageRating)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<BookDetailBean> {
        override fun createFromParcel(parcel: Parcel): BookDetailBean {
            return BookDetailBean(parcel)
        }

        override fun newArray(size: Int): Array<BookDetailBean?> {
            return arrayOfNulls(size)
        }
    }

}